import request from '@/utils/request'

export default {
  getUserList(searchModel) {
    return request({
      url: '/api/sys/user/list',
      method: 'get',
      params: {
        pageNum: searchModel.pageNum,
        pageSize: searchModel.pageSize,
        userName: searchModel.username,
        statusId: searchModel.statusId
      }
    })
  },

  addUser(user) {
    return request({
      url: '/api/sys/user/add',
      method: 'post',
      data: user
    })
  },

  updateUser(user) {
    return request({
      url: '/api/sys/user/update',
      method: 'post',
      data: user
    })
  },
  saveUser(user) {
    if (user.id == null && user.id == undefined) {
      return this.addUser(user);
    }
    return this.updateUser(user);
  },

  deleteUserById(deleteUser) {
    return request({
      url: `/api/sys/user/delete`,
      method: 'delete',
      data: deleteUser
    })
  },

  register(user) {
    return request({
      url: '/api/sys/user/register',
      method: 'post',
      data: user
    })
  },

  freezeUser(id) {
    return request({
      url: `/api/sys/user/freeze`,
      method: 'post',
      params: {
        userId: id,
      }
    })
  },

  unfreezeUser(id) {
    return request({
      url: `/api/sys/user/unfreeze`,
      method: 'post',
      params: {
        userId: id,
      }
    })
  },

  getVoList() {
    return request({
      url: '/api/sys/user/vo_list',
      method: 'get',
    })
  }
}
